package com.z.xhelper.core.listener.sends;

import com.z.xhelper.core.config.Consts;
import com.z.xhelper.core.utils.HttpsUtil;
import com.z.xhelper.core.utils.LogUtil;

import org.json.JSONObject;

public class BindUidAction{

    public static boolean doAction(String context) {
        if (!context.contains(Consts.INIT_PRE)){
            return false;
        }
        String client = context.split(Consts.INIT_PRE)[1];
        String robotWxId = Consts.ROBOT_WXID;
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put(Consts.BIND_CLIENT_ID,client);
            jsonObject.put(Consts.BIND_UID,robotWxId);
            String jsonData = jsonObject.toString();
            LogUtil.log("绑定客户端" + jsonData);
            String res = HttpsUtil.postJson(jsonData, Consts.ROBOT_BIND_CLIENT_URL);
            LogUtil.log("绑定客户端返回值" + res);
        }catch (Exception e){
            LogUtil.log("绑定客户端失败" + e.getMessage());
        }
        return true;
    }
}
